package com.clqteam.controller;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.clqteam.model.Employee;
import com.clqteam.model.Supplier;
import com.clqteam.service.SelectSupplierService;
import com.clqteam.serviceimpl.SelectSupplierServiceImpl;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
/**LXG
 * 模糊查询功能的controller
 * @author Administrator LXG
 *
 */
public class SelectSupplierController extends HttpServlet{
	SelectSupplierService sss=new SelectSupplierServiceImpl();
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		doPost(req, resp);
		
	}
	
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		resp.setCharacterEncoding("utf8");
		req.setCharacterEncoding("utf8");
			
		String keyword=req.getParameter("keyword");
		String pa=req.getParameter("page");
		int page=Integer.parseInt(pa);
		String row=req.getParameter("rows");
		int rows=Integer.parseInt(row);
		JSONObject jo=sss.selectSupplier(keyword, page, rows);
		
		PrintWriter pw=resp.getWriter();
		
		pw.write(jo.toString());
		pw.flush();
		pw.close();
		
	}
}
